﻿using System;
using System.Collections.Generic;
using System.Text;

using Fluid.Controls;
using Close.controls.MenuPanels;
using System.Drawing;

namespace Close.Controls
{
    class LevelListBox : ListBoxBase
    {
        private SelectLevelTemplate detail;

        protected override void InitControl()
        {
            base.InitControl();
            //ShowHeader = false;
            detail = new SelectLevelTemplate();
            ItemTemplate = detail;
            ItemHeight = ItemTemplate.Height;
        }

        public LevelListBoxItem Item { get { return GetItem(SelectedItemIndex) as LevelListBoxItem; } }

        public string SelectedText { get { return ((GameDetail)GetItem(SelectedItemIndex)).Id.ToString(); } }

        private void LevelListBox_ItemClick(object source, ListBoxItemEventArgs e)
        {
            //e.ItemIndex
        }
        //protected override void OnItemClick(int index)
        //{
        //    base.OnItemClick(index);
        //    //Item

        //    /*
        //    if (!Item.IsUsed)
        //    {
        //        PasswordCategory category = Item.Category;
        //        if (category != null)
        //        {
        //            ListBuilder.Instance.AddCategory(category.Clone());
        //            CategoriesPanel.Close();
        //        }
        //    }
        //     */
        //}
        /*
        public List<LevelListBoxItem> Categories { get; private set; }

        public CategoriesPanel CategoriesPanel { get { return Parent as CategoriesPanel; } }

        




        internal void UpdateData()
        {
            Categories = ListBuilder.Instance.DefaultCategories;
            DataSource = Categories;
            this.SelectFirstDataItem();
        }

        public override void OnKeyDown(System.Windows.Forms.KeyEventArgs e)
        {
            base.OnKeyDown(e);
            if (!e.Handled)
            {
                switch (e.KeyCode)
                {
                    case System.Windows.Forms.Keys.Right:
                        e.Handled = true;
                        AddItem();
                        break;

                    case System.Windows.Forms.Keys.Left:
                        e.Handled = true;
                        RemoveItem();
                        break;

                }
            }
        }



        private void RemoveItem()
        {
            LevelListBoxItem item = Item as LevelListBoxItem;
            if (item != null)
            {
                item.IsUsed = false;
                InvalidateItem(SelectedItemIndex);
            }

        }

        public override void AddItem()
        {
            LevelListBoxItem item = Item as LevelListBoxItem;
            if (item != null)
            {
                item.IsUsed = true;
                InvalidateItem(SelectedItemIndex);
            }
        }
*/
    }
         
}
